package org.hellhouse.thehungryslingshot.view;

import android.graphics.Canvas;
import android.view.SurfaceHolder;

public class WorldView extends Thread{

	private Panel panel;
	private SurfaceHolder surfaceHolder;
	private boolean isRunning = false;

	public WorldView(Panel panel) {
		this.panel = panel;
		surfaceHolder = panel.getHolder();
	}

	public void setRunning(boolean run) {
		isRunning = run;
	}

	@Override
	public void run() {
		Canvas canvas = null;
		while (isRunning) {
			canvas = surfaceHolder.lockCanvas();
			if (canvas != null) {
				panel.doDraw(canvas);
				surfaceHolder.unlockCanvasAndPost(canvas);
			}
		}
	}
}
